package com.wondersgroup.fjzlpt.org.controller.view.wdqyhz;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.wondersgroup.fjzlpt.org.service.inter.jtqy.JtqyService;
import com.wondersgroup.fjzlpt.org.util.ControllerCommonUtil;
import com.quick.framework.util.QuickPrincipalUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.wapper.QuickPrincipal;
import com.wondersgroup.fjzlpt.org.service.inter.gzt.GztService;
import com.wondersgroup.fjzlpt.org.service.inter.wdqyhz.WdqyhzService;


@Controller
@RequestMapping("/wdqyhz")
public class WdqyhzController {

	@Autowired
	private WdqyhzService wdqyhzService;
	@Autowired
	private GztService gztService;
	@Autowired
	private JtqyService jtqyService;

	/**
	 * 我的签约患者主页面
	 * @return
	 */
	@RequestMapping("index.html")
	public String index(HttpServletRequest request){
		Map map = ControllerCommonUtil.getQueryTdxxParams(request);
		JSONArray TDXX = jtqyService.queryTdxxAll(map);
		request.setAttribute("tdxxArr", TDXX);
		return "wdqyhz/index";
	}
	
	/**
	 * 服务记录
	 * @return
	 */
	@RequestMapping("fwjl.html")
	public String fwjl(HttpServletRequest request){
		Map map = ControllerCommonUtil.getQueryTdxxParams(request);
		JSONArray TDXX = jtqyService.queryTdxxAll(map);
		request.setAttribute("tdxxArr", TDXX);
		return "wdqyhz/fwjl";
	}
	
	/**
	 * 分配任务
	 * @return
	 */
	@RequestMapping("fprw.html")
	public String fprw(){
		return "wdqyhz/fprw";
	}

    /**
     * 批量分配任务
     *
     * @return
     */
    @RequestMapping("fprwBatch.html")
    public String fprwBatch(HttpServletRequest request) {
        //根据用户查询他所拥有的团队的团队成员
        Map<String, String> map = new HashMap<String, String>();
        map.put("USERID", QuickPrincipalUtils.getUserID(request));
        map.put("TDZT", "1");
        map.put("TDJS", "1");
        JSONObject tdryObj = wdqyhzService.queryTdryByUserInfo(map);
        request.setAttribute("tdryObj", tdryObj);
		return "wdqyhz/fprwBatch";
	}
	
	/**
	 * 删除已分配任务
	 * @return
	 */
	@RequestMapping("deleteYfprw.html")
	public String deleteYfprw(){
		return "wdqyhz/deleteYfprw";
	}
	
	/**
	 * 修改已分配任务
	 * @return
	 */
	@RequestMapping("updateYfprw.html")
	public String updateYfprw(){
		return "wdqyhz/updateYfprw";
	}
	
	/**
	 * 修改已分配任务
	 * @return
	 */
	@RequestMapping("ckfw.html")
	public String ckfw(){
		return "wdqyhz/ckfw";
	}
	
	/**
	 * 完成任务
	 * @return
	 */
	@RequestMapping("wcrw.html")
	public String wcrw(HttpServletRequest request){
		request.setAttribute("XM",QuickPrincipalUtils.getUserinfoByKey(request,"XM"));
		return "wdqyhz/wcrw";
	}
	
	/**
	 * 任务管理
	 * @return
	 */
	@RequestMapping("rwgl.html")
	public String rwgl(HttpServletRequest request){
		Map map = ControllerCommonUtil.getQueryTdxxParams(request);
		map.put("TDJS","1");
		JSONArray TDXX = jtqyService.queryTdxxAll(map);
		request.setAttribute("tdxxArr", TDXX);
		return "wdqyhz/rwgl";
	}
	
	/**
	 * 历史签约服务
	 * @return
	 */
	@RequestMapping("historyQyfw.html")
	public String historyQyfw(HttpServletRequest request){
		return "wdqyhz/historyQyfw";
    }



    /**
     * 转诊列表
     * @return
     */
    @RequestMapping("/zzlb.html")
    public String zzlb(HttpServletRequest request) {
        String sfzh = (String) QuickPrincipalUtils.getUserinfoByKey(request, "SFZH");
		return "redirect:" + ControllerCommonUtil.getSxzzlistUrl() + sfzh;
    }

}
